package edu.neu.highway.controller;

import edu.neu.highway.service.IFluxImportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <h1>数据导入接口定义</h1>
 */
@RestController
@Api(tags = "流量数据导入")
@Slf4j
@RequestMapping("/import-flow")
public class FluxImportController {

    private final IFluxImportService fluxImportService;

    public FluxImportController(IFluxImportService fluxImportService) {
        this.fluxImportService = fluxImportService;
    }

    @ApiOperation(value = "导入数据", notes = "导入行协议数据", httpMethod = "POST")
    @PostMapping("/line")
    public void importFlowByLineProtocol(@RequestBody String line) {
        log.info("flux import:[{}]", line);
        fluxImportService.fluxImportByLineProtocol(line);
    }
}
